package com.css.zfzx.sjcj.modules.hddcGeologicalSvyPlanningLine.repository;

import com.css.zfzx.sjcj.modules.hddcGeologicalSvyPlanningLine.repository.entity.HddcGeologicalsvyplanninglineEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zyb
 * @date 2020-12-07
 */
public interface HddcGeologicalsvyplanninglineRepository extends JpaRepository<HddcGeologicalsvyplanninglineEntity, String> {

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyplanningline where is_valid !=0 and project_name in :projectIds")
    List<HddcGeologicalsvyplanninglineEntity> queryHddcGeologicalsvyplanninglinesByProjectId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyplanningline where is_valid !=0 and task_name in :taskIds")
    List<HddcGeologicalsvyplanninglineEntity> queryHddcGeologicalsvyplanninglinesByTaskId(List<String> taskIds);

    @Query(nativeQuery = true, value = "delete from hddc_geologicalsvyplanningline where uuid = :uuid")
    void deleteHddcGeologicalsvyplanninglinesByCreateUser(String uuid);

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyplanningline where create_user = :createuser and province = :provinceName and city =:cityName and area =:areaName")
    List<HddcGeologicalsvyplanninglineEntity> queryHddcGeologicalsvyplanninglinesByCreateuser(String createuser,String provinceName,String cityName,String areaName);

    @Query(nativeQuery = true, value = "select * from hddc_geologicalsvyplanningline where is_valid ='1'")
    List<HddcGeologicalsvyplanninglineEntity> findAll();

    @Modifying
    @Query(nativeQuery = true, value = "update hddc_geologicalsvyplanningline set is_valid ='0' " +
            " where province = :provinceName and city =:cityName and area =:areaName and extends8 =:savefilename")
    void deleteFileData(String provinceName,String cityName,String areaName,String savefilename);

}
